﻿using System;
using System.Collections.Generic;
using System.Text;

namespace RedisService
{
    public interface IDatabase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expiry">多少毫秒之后过期（单位毫秒）</param>
        /// <param name="keyState">key的状态，</param>
        /// <returns></returns>
        bool StringSet(string key, string value, Int32? expiry = null, KeyState keyState = KeyState.Always);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="offset"></param>
        /// <param name="bit"></param>
        /// <returns></returns>
        bool StringSetBit(string key, long offset, bool bit);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        long StringIncr(string key, long value = 1);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        long StringDecr(string key, long value = 1);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string StringGet(string key);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        bool StringGetBit(string key, long offset);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Del(string key);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expiry"></param>
        /// <returns></returns>
        bool Lock(string key, string value, Int32 expiry);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool Unlock(string key, string value);
        /// <summary>
        /// 在列表的左边插入一个元素
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="keyState"></param>
        /// <returns></returns>
        long LPush(string key, string value, KeyState keyState = KeyState.Always);
        /// <summary>
        /// 在列表的右边插入一个元素
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="keyState"></param>
        /// <returns></returns>
        long RPush(string key, string value, KeyState keyState = KeyState.Always);
        /// <summary>
        /// 在列表的左边插入多个元素
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="keyState"></param>
        /// <returns></returns>
        long LPush(string key, string[] value, KeyState keyState = KeyState.Always);
        /// <summary>
        /// 在列表的右边插入多个元素
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="keyState"></param>
        /// <returns></returns>
        long RPush(string key, string[] value, KeyState keyState = KeyState.Always);
        /// <summary>
        /// 从列表的左边弹出一个元素
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string LPop(string key);
        /// <summary>
        /// 从列表的右边弹出一个元素
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string RPop(string key);
        /// <summary>
        /// 队列的长度
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        long LLen(string key);
        /// <summary>
        /// 返回指定范围的值，（不会移除数据）
        /// </summary>
        /// <param name="key"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        string[] LRange(string key, long start, long end); 
    }
} 
